package com.bdc.base;

import com.bdc.BdcVar;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.persist.jpa.JpaPersistModule;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.struts2.Struts2GuicePluginModule;
import org.apache.log4j.Logger;

/**
 * User: shawn
 * Date: 2011-6-13
 * Time: 0:04:04
 */
public class GuiceListener extends GuiceServletContextListener {

    private Logger logger = Logger.getLogger(GuiceListener.class.getName());

    @Override
    protected Injector getInjector() {
        logger.debug("GuiceListener Start");
        BdcVar.injector = Guice.createInjector(new Struts2GuicePluginModule(), new JpaPersistModule("hibernate"), new AppServletModule());
        return BdcVar.injector;
    }
}
